package com.shotinthedark
{
	import com.common.utils.Graphics2;
	import com.shootingGame.HealthBar;
	
	public class CircularHealthBar extends HealthBar
	{
		public static const green : uint = 0x2DE817;
		public static const yellow : uint = 0xFFCC00;//0xFFFF00;
		public static const red : uint = 0xFF3300;
		
		public function CircularHealthBar()
		{
//			var colors:Array = new Array();
//			var alphas:Array = new Array();
//			var ratios:Array = new Array();

//			colors.push(0x2DE817);
//			colors.push(0xFF0000);
//			ratios.push(0,255)
//			alphas.push(1,1);
//			//colors.push(Color.
//			graphics.lineStyle(2);
			//graphics.beginFill(0x2DE817);
//			//graphics.beginGradientFill(GradientType.LINEAR, colors, alphas, ratios);
//			graphics.lineGradientStyle(GradientType.LINEAR, colors, alphas, ratios);
//			graphics.drawCircle(0,0,20);
//			graphics.drawCircle(0,0,40);			
			
			healthPercentage = 1;

		}
		

		
		override public function set healthPercentage(value : Number) {
			super.healthPercentage = value;
			var outerRadius:Number = 25;
			var innerRadius:Number = 17;
			var radiansToDraw:Number = 2 * Math.PI/100 * _healthPercentage * 100;
			var color:uint;
			if(_healthPercentage >= 0.75)
				color = green;
			else
				if(_healthPercentage >= 0.3)
					color = yellow;
				else
					color = red;
			
//			graphics.lineStyle(2,0xFF0000, 0.5);
	        graphics.beginFill(color, 1.0);
	        graphics.moveTo(innerRadius, 0);
	        Graphics2.drawArc(graphics, 0,0,0, radiansToDraw ,innerRadius,1);
	        graphics.lineTo(Math.cos(radiansToDraw) * outerRadius, Math.sin(radiansToDraw) * outerRadius);
	        Graphics2.drawArc(graphics, 0,0,0, radiansToDraw,outerRadius,1);
	        graphics.lineTo(innerRadius, 0);
	        graphics.endFill();
		}
		
		

	}
}